﻿using BaseFunction;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using YY.Common;

namespace YY.Web.MyAgent
{
    public partial class AgentUserInfor : BaseFunction.LoginHelp
    { protected int totalCount;
        protected int page;
        protected int pageSize;

        protected string keywords = string.Empty;
        protected void Page_Load(object sender, EventArgs e)
        {
            //按条件查询
            this.keywords = BaseFunction.RequestValidate.GetQueryString("keywords", "");

            this.pageSize = GetPageSize(10); //每页数量
            if (!IsPostBack)
            {
                RptBind();
            }
        }
         private void RptBind()
        {
            this.page = BaseFunction.RequestValidate.GetQueryInt("page", 1);
            string sql = "SELECT  order_time, registered_time, installation_time, server_record,  UserName, TrueName, IDNumber,  Gender, Age, PhoneNumberOne,Email, ContactAddress  FROM dbo.tb_UserInfor a,dbo.tb_agent_users_relationship b   WHERE b.member_id=a.UId";
            DataSet ds = MsSql2008.ExecSqlPagerPROCEDURE(sql, 1, pageSize);
            totalCount = int.Parse(ds.Tables[1].Rows[0]["TotalCount"] + "");
            this.rptList.DataSource = ds.Tables[2];
            this.rptList.DataBind();

            //绑定页码
            txtPageNum.Text = this.pageSize.ToString();
            string pageUrl = Utils.CombUrlTxt("express_moban.aspx", "keywords={0}&page={1}", this.keywords, "__id__");
            //显示分页 PageContent.InnerHtml = Utils.OutPageList(this.pageSize, this.page, this.totalCount, pageUrl, 8);
        }
   

        #region 组合SQL查询语句==========================
        protected string CombSqlTxt(string _keywords)
        {
            StringBuilder strTemp = new StringBuilder();
            _keywords = _keywords.Replace("'", "");
            if (!string.IsNullOrEmpty(_keywords))
            {
                strTemp.Append(" and Name like  ''%" + _keywords + "%''");
            }

            return strTemp.ToString();
        }
        #endregion

        #region 返回每页数量=============================
        private int GetPageSize(int _default_size)
        {
            int _pagesize;
            if (int.TryParse(Utils.GetCookie("spec_page_size", "YYMALLPAGE"), out _pagesize))
            {
                if (_pagesize > 0)
                {
                    return _pagesize;
                }
            }
            return _default_size;
        }
        #endregion

      
     
        //设置分页数量
        protected void txtPageNum_TextChanged(object sender, EventArgs e)
        {
            int _pagesize;
            if (int.TryParse(txtPageNum.Text.Trim(), out _pagesize))
            {
                if (_pagesize > 0)
                {
                    Utils.WriteCookie("spec_page_size", "YYMALLPAGE", _pagesize.ToString(), 14400);
                }
            }
            Response.Redirect(Utils.CombUrlTxt("express_moban.aspx", "keywords={0}", this.keywords));
        }

     
     
       
    }
}